package com.mt.roll.report.controller;

import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.report.params.ReportSheetParam;
import com.mt.roll.report.params.ReportSheetQueryParam;
import com.mt.roll.report.service.ReportSheetService;
import com.mt.roll.report.vo.ReportSheetVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;
import java.util.List;

/**
 * @Author: liguanghao
 * @Date: 2021/3/1 14:18
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_REPORT+"report-sheet")
@Slf4j
@Api(value = "报表管理", tags = "报表管理",hidden = false)
public class ReportSheetController {

    @Autowired
    private ReportSheetService reportSheetService;

    @PostMapping(value = "get")
    @ApiOperation(value = "获取报表")
    private R<ReportSheetVo> get(@Validated @RequestBody IdParam idParam) {
        return reportSheetService.get(idParam);
    }

    @PostMapping(value = "list")
    @ApiOperation(value = "获取报表列表")
    private R<List<ReportSheetVo>> list(@Validated({Default.class}) @RequestBody ReportSheetQueryParam reportSheetQueryParam) {
        return reportSheetService.list(reportSheetQueryParam);
    }

    @PostMapping(value = "page")
    @ApiOperation(value = "获取分页报表")
    private R<PageVo<ReportSheetVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody ReportSheetQueryParam reportSheetQueryParam) {
        return reportSheetService.page(reportSheetQueryParam);
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "新增")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody ReportSheetParam reportSheetParam) {
        return reportSheetService.add(reportSheetParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody ReportSheetParam reportSheetParam) {
        return reportSheetService.update(reportSheetParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除报表")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return reportSheetService.delete(idParam);
    }

}
